Object oAll= current
Module m = current
int iThisAbsNum = obj."Absolute Number"
int iAbsNum
int iCount= 1
string sRate
string sNum
int iOffset, iLength
for oAll in m do {
sRate= oAll ."Rate" //Grabs string from 'Rate' attribute from current object
iAbsNum= oAll."Absolute Number"
//Grabs Absolute object number of current object
sNum= oAll."Priority Number"
//Grabs string from 'Priority Number' attribute from the current object (***This DXL attribute is used to define the 'Priority Number' attribute)
if(findPlainText (sRate, "High", iOffset, iLength, false)) {
//If the 'Rate' attribute is 'High' then execute the following
if(iAbsNum == iThisAbsNum) {
//If the current object number matches the absolute object number execute the follow
if(intOf(sNum)==iCount)
//If the current 'Priority Number is equal to the current count simply display the count
displayRich("\\pard " iCount "")
else
obj."Change Flag"="True"
//If the current 'Priority Number is NOT equal to the current count set the 'Change Flag' attribute to 'True' and then display the current count
displayRich("\\pard " iCount "")
}
else iCount++
}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I want to adjust one of my DXL attributes so that when the attribute changes to a different value it changes the value of a different attribute (shown highlighted in yellow). Is this possible (I'm essentially creating a changebar for one particular attribute)? I keep getting a syntax error and/or cause DOORS to crash. Aside: Is there a way to only run a DXL attribute only when a certain view is active AND no filters are being used? stevenson - Tue Feb 11 16:05:38 EST 2014 |
Re: DXL Attribute Writes To Another Attribute Apparently you can't highlight code... |
Re: DXL Attribute Writes To Another Attribute stevenson - Tue Feb 11 16:07:53 EST 2014 Apparently you can't highlight code... Whoops I just saw, that this was totally not your question ;-) Anyway I keep that post for reference .... I saw some green highlight flashing in your above code, when I loaded the page, but it disappeared immediately. You can use the rtf \highlight tag to highlight stuff in DOORS DXL attributes (that do usually not support colored text). But for this to work, you need to have a color table in your attribute like in the following richtext (copied from Wordpad to DOORS)
{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
{\colortbl ;\red255\green255\blue0;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\highlight1\lang7\f0\fs20 Hallo\highlight0\lang1031\par
}
Post this code to a DXL attirbute:
string sHeader = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1031{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}"
string s = "";
string sColorTable = "{\\colortbl ";
int i; for (i = 0; i < 20; i++) {
int r = random(255), b = random(255), g = random(255);
sColorTable = sColorTable ";\\red" r "\\green" g "\\blue" b ";"
s = s "{\\highlight" i "Hallo: " r "," g "," b "}\\par"
}
obj.attrDXLName = richText sHeader sColorTable "}" s "}"
Maybe that helps, regards, Mathias |
Re: DXL Attribute Writes To Another Attribute Ok, to your original question: First of all you need to clarify if you mean "DXL Attribute" or "DXL Layout" ... Since in your code you are using displayRich which is a function for DXL Layouts only I assume you are doing a DXL Layout Column. If this is the case, then it is a bad idea to try to modify an attribute from a DXL layout. Secondly I hope that these comments in your code are only for reference and not in your real code. If statements with a comment between them are a bad idea:
if (true == false) // now is that a cool comment
print "This is not printed"
if (true == false)
// ouchie!
print "This will be printed because the IF statement will use the comment"
if (true == false) {
// always use braces to be sure
print "Now this will never happen!"
}
So coming back to the Layout DXL / Attribute DXL question. If you want a change bar you should use another way, for example a dynamic trigger or a DXL Layout / Attribute that evaluates history to check if there has been a modification made in the current session. This way you do not even need to have an attribute "Change Flag" in your module. You can store that Layout DXL in a column inside a view, so it will only be executed when you open the view. Here is an example that implements something like a change bar if the user changed the Object Text in the current Session (since he started DOORS) of course you can have another criterion (since the last baseline, since going to edit mode, etc.)
History h
// returns the date when the user started his DOORS ..
Date dSession = session();
bool bChange = false;
// You could also get the current edit session from the DOORS module history
// and compare this one
for h in obj do {
HistoryType ht = h.type
int historySession = h.sessionNo
Date hDate = dateAndTime h.date;
if (ht == modifyObject && hDate >= dSession) {
string sAttr = h.attrName
if (sAttr == "Object Text") {
bChange = true;
break
}
}
}
if (bChange) display "Changed!"
Maybe this helps, regards, Mathias |
Re: DXL Attribute Writes To Another Attribute MM's solution looks good, if you are trying to see if you have modified the attr value during the current session. I'm thinking though it may be a computational hog, looping through History so very often. I'll comment on your original code:
If you are after change bars for some time in the past, perhaps since the last Baseline (Yellow if saved, Red if changed but not yet saved), then MM's solution in an Attr-DXL (deleting the date-check) combined with a post-attr-save trigger could do the trick.
-Louie |